
instance Spell_SummonMud(C_Spell_Proto)
{
	time_per_mana = 0;
	spellType = SPELL_BAD;
	targetCollectAlgo = TARGET_COLLECT_NONE;
};


func void b_printteleporttoofaraways(var int level)
{
	if(level != CurrentLevel)
	{
		PrintScreen(PRINT_TeleportTooFarAway,-1,YPOS_LevelUp,FONT_ScreenSmall,2);
	};
};

func int Spell_Logic_SummonMud(var int manaInvested)
{
	if(Npc_GetActiveSpellIsScroll(self) && (self.attribute[ATR_MANA] >= SPL_Cost_Scroll))
	{
		return SPL_SENDCAST;
	}
	else if(self.attribute[ATR_MANA] >= SPL_Cost_Teleport)
	{
		return SPL_SENDCAST;
	};
	return SPL_NEXTLEVEL;
};

func void Spell_Cast_SummonMud()
{
	if(Npc_IsPlayer(self))
	{
		if(CurrentLevel == NEWWORLD_ZEN)
		{
			if(Npc_GetActiveSpellIsScroll(self))
			{
				self.attribute[ATR_MANA] = self.attribute[ATR_MANA] - SPL_Cost_Scroll;
			}
			else
			{
				self.attribute[ATR_MANA] = self.attribute[ATR_MANA] - SPL_Cost_Teleport;
			};
			if(ALLGUARDIANSKILLED == FALSE)
			{
				AI_Teleport(hero,"NW_GUARDIANS_CHAMBER");
				Wld_SetTime(20,0);
			}
			else
			{
				PrintScreen(PRINT_TeleportTooFarAway,-1,YPOS_LevelUp,FONT_ScreenSmall,2);
				B_Say(self,self,"$DONTWORK");
			};
		}
		else if(CurrentLevel == DRAGONISLAND_ZEN)
		{
			if(Npc_GetActiveSpellIsScroll(self))
			{
				self.attribute[ATR_MANA] = self.attribute[ATR_MANA] - SPL_Cost_Scroll;
			}
			else
			{
				self.attribute[ATR_MANA] = self.attribute[ATR_MANA] - SPL_Cost_Teleport;
			};
			if(DAGOTTELLALL == TRUE)
			{
				AI_Teleport(hero,"WP_UNDEAD_CENTER_01");
				PrintScreen(PRINT_TeleportTooFarAway,-1,YPOS_LevelUp,FONT_ScreenSmall,2);
			}
			else
			{
				B_Say(self,self,"$DONTWORK");
			};
		}
		else
		{
			PrintScreen(PRINT_TeleportTooFarAway,-1,YPOS_LevelUp,FONT_ScreenSmall,2);
			B_Say(self,self,"$DONTWORK");
		};
	}
	else
	{
		if(Npc_GetActiveSpellIsScroll(self))
		{
			self.attribute[ATR_MANA] = self.attribute[ATR_MANA] - SPL_Cost_Scroll;
		}
		else
		{
			self.attribute[ATR_MANA] = self.attribute[ATR_MANA] - SPL_Cost_Teleport;
		};
		AI_Teleport(self,"TOT");
		AI_PlayAni(self,"T_HEASHOOT_2_STAND");
	};
};

